/*
 * 2011.cpp
 *
 *  Created on: 2012-5-21
 *      Author: ncrd
 */




#include <cstdio>
#include <iostream>
#include <cstdlib>

using namespace std;

#define SIZE 110

int a[SIZE];
int b[SIZE];

int compare (const void * a1, const void * b1) {
	return (*((int *)a1) - *((int *)b1));
}

int searchMid (int aStart, int aEnd, int bStart, int bEnd) {
	int aMid = (aEnd + aStart + 1)/2;
	int bMid = (bEnd + bStart + 1)/2;
	if ((aEnd-aStart)==0 || (bEnd-bStart)==0) {
		if ((aEnd-aStart)==0) {
			if (((bEnd-bStart+1)%2) == 0) {
				if (b[bMid] < a[aMid]) return b[bMid];
				else if (b[bMid-1] < a[aMid]) return a[aMid];
				else return b[bMid-1];
			} else {
				return max(b[bMid], a[aMid]);
			}
		} else {
			if (((aEnd-aStart+1)%2) == 0) {
				if (a[aMid] < b[bMid]) return a[aMid];
				else if (a[aMid-1] < b[bMid]) return b[bMid];
				else return a[aMid-1];
			}
			else return max(a[aMid], b[bMid]);
		}
	}
	if (a[aMid] == b[bMid]) {
		return a[aMid];
	} else if (a[aMid] < b[bMid]) {
		return searchMid(aMid, aEnd, bStart, bMid);
	} else{
		return searchMid(aStart, aMid, bMid, bEnd);
	}
}

int main (void) {
	int n, m;
	cin >> n >> m;
	for (int i=0; i<n; i++)
		scanf("%d", &a[i]);
	for (int i=0; i<m; i++)
		scanf("%d", &b[i]);
	qsort(a, n, sizeof(int), compare);
	qsort(b, m, sizeof(int), compare);
	cout << searchMid(0, n-1, 0, m-1) << endl;
}
